package com.designpattern.IteratorPattern;


import java.util.ArrayList;
import java.util.List;

/**
 * @Author yue
 * @Date 2021-07-26
 * @Version V1.0.1
 * @Description 抽象聚合
 */

public interface Aggregate {
    public void add(Object obj);
    public void remove(Object obj);
    public Iterator getIterator();
}

//具体聚合
class ConcreteAggregate implements Aggregate {
    private List<Object> list = new ArrayList<Object>();
    public void add(Object obj) {
        list.add(obj);
    }
    public void remove(Object obj) {
        list.remove(obj);
    }

    public Iterator getIterator() {
        return (new ConcreteIterator(list));
    }
}
